OPC Studio User's Guide and Reference
User Interface Objects
View with Navigation Tools
Fundamentals > QuickOPC Fundamentals > QuickOPC Data Model > User Interface Objects

In QuickOPC “Classic” and QuickOPC-UA, you instantiate a user interface object in Windows Forms applications by dragging the appropriate component from the Toolbox to the designer surface. The designer creates code that instantiates the component, assigns a reference to it to a field in the parent component, and sets its properties as necessary. You can then use designer’s features such as the Properties grid to manipulate the component.

If the needed components do not show in the Toolbox: See Troubleshooting the Visual Studio Extension.

You can, of course, instantiate the user interface objects from your code as well, by calling the appropriate constructors.

In QuickOPC-COM and QuickOPC-UA for COM, you can use some of the user interface objects (namely, the dialogs – but not the controls) as well. Create the objects as any other QuickOPC objects on the COM platforms. The convention described earlier (with communication objects) always applies, and therefore the ProgIDs of the user interface objects are the same as the namespace-qualified names of corresponding .NET types.

In runtime, all user interface features (such as controls, dialogs, and live binding; Windows Forms and WPF) and non-visual components are supported both under .NET Framework and .NET 6+. However, "designing" them (this includes tasks like dragging from the Toolbox, or configuring in Properties window) in Visual Studio is only possible in .NET Framework projects. In order to achieve visual design for .NET 6+ projects, the developer can make two project files over the same set of source files, one targeting .NET Framework and one targeting .NET 6+, and use the project that targets .NET Framework for visual design tasks.

The features discussed here, or some of them, may not be available in all editions of the product. Check the QuickOPC Product Editions page for differences between the editions. The trial license has all features enabled (and is limited in period for which it provides valid data), but licenses for specific commercial editions may have functionality limitations.

Examples

The following examples instantiate the user interface objects directly in the code.

.NET

// This example shows how to let the user browse for an OPC Data Access item. 
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
// OPC client and subscriber examples in C# on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-CSharp .
// Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
// a commercial license in order to use Online Forums, and we reply to every post.

using System.Windows.Forms;
using OpcLabs.EasyOpc.DataAccess.Forms.Browsing;

namespace FormsDocExamples._DAItemDialog
{
    static class ShowDialog
    {
        public static void Main1(IWin32Window owner)
        {
            var itemDialog = new DAItemDialog
            {
                ServerDescriptor = {ServerClass = "OPCLabs.KitServer.2"}
            };

            DialogResult dialogResult = itemDialog.ShowDialog(owner);
            if (dialogResult != DialogResult.OK)
                return;

            // Display results
            MessageBox.Show(owner, $"NodeElement: {itemDialog.NodeElement}");
        }
    }
}

COM

// This example shows how to let the user browse for an OPC Data Access item.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
// OPC client and subscriber examples in Object Pascal (Delphi) on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-OP .
// Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
// a commercial license in order to use Online Forums, and we reply to every post.

class procedure ShowDialog.Main;
var
  ItemDialog: OpcLabs_EasyOpcForms_TLB._DAItemDialog;
begin
  // Instantiate the dialog object
  ItemDialog := CoDAItemDialog.Create;

  ItemDialog.ServerDescriptor.ServerClass := 'OPCLabs.KitServer.2';

  ItemDialog.ShowDialog(nil);

  // Display results
  WriteLn(ItemDialog.NodeElement.ToString);
end;

Python

# This example shows how to let the user browse for an OPC Data Access item.
#
# Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
# OPC client and subscriber examples in Python on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-Python .
# Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
# a commercial license in order to use Online Forums, and we reply to every post.
# The QuickOPC package is needed. Install it using "pip install opclabs_quickopc".
import opclabs_quickopc

# Import .NET namespaces.
from System.Windows.Forms import *
from OpcLabs.EasyOpc.DataAccess.Forms.Browsing import *


itemDialog = DAItemDialog()
itemDialog.ServerDescriptor.ServerClass = "OPCLabs.KitServer.2"

dialogResult = itemDialog.ShowDialog()
print(dialogResult)
if dialogResult != DialogResult.OK:
    exit()

# Display results.
print('NodeElement: ', itemDialog.NodeElement, sep='')

 

 

.NET

// This example shows how to let the user browse for an OPC-UA data node (a Data Variable or a Property). 
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
// OPC client and subscriber examples in C# on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-CSharp .
// Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
// a commercial license in order to use Online Forums, and we reply to every post.

using System.Windows.Forms;
using OpcLabs.EasyOpc.UA.Forms.Browsing;

namespace UAFormsDocExamples._UADataDialog
{
    static partial class ShowDialog
    {
        public static void Main1(IWin32Window owner)
        {
            var dataDialog = new UADataDialog
            {
                EndpointDescriptor = {UrlString = "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer" },
                // or "http://opcua.demo-this.com:51211/UA/SampleServer" (currently not supported)
                // or "https://opcua.demo-this.com:51212/UA/SampleServer/"
                UserPickEndpoint = true
            };

            DialogResult dialogResult = dataDialog.ShowDialog(owner);
            if (dialogResult != DialogResult.OK)
                return;

            // Display results
            MessageBox.Show(owner, 
                $"EndpointDescriptor: {dataDialog.EndpointDescriptor}\r\n" +
                $"NodeElement: {dataDialog.NodeElement}");
        }
    }
}

COM

// This example shows how to let the user browse for an OPC-UA data node (a Data Variable or a Property).
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
// Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
// a commercial license in order to use Online Forums, and we reply to every post.

#include "stdafx.h"    // Includes "QuickOpc.h", and other commonly used files
#include "ShowDialog.h"

namespace _UADataDialog
{
    void ShowDialog::Main()
    {
        // Initialize the COM library
        CoInitializeEx(NULL, COINIT_MULTITHREADED);
        {
            // 
            _UADataDialogPtr DataDialogPtr(__uuidof(UADataDialog));

            //
            DataDialogPtr->EndpointDescriptor->UrlString = 
                //L"http://opcua.demo-this.com:51211/UA/SampleServer";
                L"opc.tcp://opcua.demo-this.com:51210/UA/SampleServer";
            DataDialogPtr->UserPickEndpoint = true;

            // 
            DialogResult dialogResult = DataDialogPtr->ShowDialog(NULL);
            // Display results

            if (dialogResult == 1/*OK*/)
            {
                _tprintf(_T("%d\n"), dialogResult);
                _tprintf(_T("EndpointDescriptor: %s\n"), (LPCTSTR)CW2CT(DataDialogPtr->EndpointDescriptor->ToString));
                _tprintf(_T("NodeElement: %s\n"), (LPCTSTR)CW2CT(DataDialogPtr->NodeElement->ToString));
            }
        }
         // Release all interface pointers BEFORE calling CoUninitialize()
        CoUninitialize();
    }
}

Python

# This example shows how to let the user browse for an OPC-UA data node (a Data Variable or a Property).
#
# Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
# OPC client and subscriber examples in Python on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-Python .
# Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
# a commercial license in order to use Online Forums, and we reply to every post.
# The QuickOPC package is needed. Install it using "pip install opclabs_quickopc".
import opclabs_quickopc

# Import .NET namespaces.
from System.Windows.Forms import *
from OpcLabs.EasyOpc.UA.Forms.Browsing import *


dataDialog = UADataDialog()
dataDialog.EndpointDescriptor.UrlString = 'opc.tcp://opcua.demo-this.com:51210/UA/SampleServer'
# or 'http://opcua.demo-this.com:51211/UA/SampleServer' (currently not supported)
# or 'https://opcua.demo-this.com:51212/UA/SampleServer/'
dataDialog.UserPickEndpoint = True

dialogResult = dataDialog.ShowDialog()
print(dialogResult)
if dialogResult != DialogResult.OK:
    exit()

# Display results.
print('EndpointDescriptor: ', dataDialog.EndpointDescriptor, sep='')
print('NodeElement: ', dataDialog.NodeElement, sep='')

print('Finished.')

 

See Also

Fundamentals

Troubleshooting